<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<a id="openBaidu">打开百度</a>
		<script>
			var url = 'http://www.baidu.com/s?name=小米';
				url = escape(url);
				console.log(url);
				console.log(unescape(url));
			var obj = { 
					name : 'jack',
					weight : '16  kg' ,
					height : '190  cm',
					toString : function(){
						return true;
					}
						
			};
			console.log('hasOwnProperty()');
			console.log('name' in obj);
			console.log('weight' in obj);
			console.log('height' in obj);
			
			console.log(obj.hasOwnProperty('toString'));
			console.log(obj.hasOwnProperty('name'));
			console.log(obj.hasOwnProperty('toLocaleString'));
			
			console.log('Math.pow()');
			var num = Math.pow(2,8);//2的8次方
			console.log(num);
			
			console.log('字符串.replace()');
			var str = 'hello world';
			console.log(str.replace('world', '没有world'));
			console.log('把Hello world, welcome to the universe. o之间的字符串提取出来');
			
//			:用for循环弹出星期一到星期天,但不弹出今天的值
			console.log('用for循环弹出星期一到星期天,但不弹出今天的值');
			var week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
			var days = new Date();
			console.log(days.getDay());
			for(var i = 0; i < week.length; i++){
				if(i == days.getDay()){
					week.splice(i, 1);
				}else{
					console.log(week[i]);
				}
			}
			
// 获得被踢出字母后的字符串			
function pickUpLetter(strings, letter){
	
			var str = strings;
			var deleteLetter = letter;
			var strIndexs = new Array();//字母 的下标集合
			var countIndexs = 0;//字母的数量
			var finishedSubStrings = '';//提取后的字符串
			var i = 0;
			
			
			while(i >= 0){
				
				if(i == 0){
					strIndexs[i] = str.indexOf(deleteLetter);
					
				}else{
					strIndexs[i] = str.indexOf(deleteLetter, strIndexs[i-1]+1);
				}
				if(strIndexs[i] < 0){
					strIndexs.length--;
					break;
				}
				i++;
			}
			countIndexs = strIndexs.length;
			
			
			for( var i = 0; i < countIndexs; i++){
				

			
				if(i == 0){
					
					strIndexs[i] = str.indexOf(deleteLetter);
					finishedSubStrings += str.substring(0, strIndexs[i]);

				}else{
					
					strIndexs[i] = str.indexOf(deleteLetter, strIndexs[i-1]+1);
					finishedSubStrings += str.substring(strIndexs[i-1]+1, strIndexs[i]);
					
				}
				
				if(i == (countIndexs - 1)){
					finishedSubStrings += str.substring(strIndexs[countIndexs - 1] + 1, str.length-1);

					break;
				}
				
			}



		console.log(finishedSubStrings);

}
			
	
			
	pickUpLetter('Today is rain day! ', 'i');
	pickUpLetter('f i n i shedSubStr i ngs ', 'i');	  
		//window.open()
		
		var btn = document.querySelector('#openBaidu');
		btn.addEventListener('click', function(){
			window.open('http://www.baidu.com', '_blank', width = 300, height = 200);
		});
		
//		history.go('背景');

// split() 获得被踢出字母后的字符串...what the fuck
 	var str1 = 'className-a';

	console.log('把Hello world, welcome to the universe. o之间的字符串提取出来 :'); 	
// 		console.log(str1.split('-')[0]);
// 		console.log(str1.split('-')[1]);
 	var str2 = 'Hello world, welcome to the universe.', finishedstring = '';
	
 		
 	 	for(var i = 0; i < str2.split('o').length; i++){
 	 		finishedstring += str2.split('o')[i]
 	 	}
 	 	console.log(finishedstring);
		</script>
	</body>
</html>
